home *** CD-ROM | disk | FTP | other *** search
/ Champak 130 / Vol 130.iso / games / target_s.swf / scripts / assets / buildings / building2.as < prev    next >
Encoding:
Text File  |  2008-11-13  |  5.7 KB  |  198 lines

  1. package assets.buildings
  2. {
  3.    import assets.buildings.parts.*;
  4.    import flash.display.*;
  5.    import flash.events.*;
  6.    import flash.geom.Point;
  7.    
  8.    [Embed(source="/_assets/assets.swf", symbol="assets.buildings.building2")]
  9.    public class building2 extends MovieClip
  10.    {
  11.        
  12.       
  13.       public var pp:Point;
  14.       
  15.       public var deep:Number = 40;
  16.       
  17.       public var space:Number = 20;
  18.       
  19.       public var scope:Object;
  20.       
  21.       public var planes:Array;
  22.       
  23.       public var dist:Number;
  24.       
  25.       public var wide:Number = 202;
  26.       
  27.       public function building2(param1:*)
  28.       {
  29.          pp = new Point(350 + 150,200);
  30.          deep = 40;
  31.          wide = 202;
  32.          space = 20;
  33.          planes = new Array();
  34.          super();
  35.          scope = param1;
  36.          setData();
  37.          addEventListener(Event.ENTER_FRAME,render);
  38.          addEventListener(Event.REMOVED_FROM_STAGE,onRemove);
  39.       }
  40.       
  41.       public function setData() : *
  42.       {
  43.          planes.push({
  44.             "A":new Point(202,0),
  45.             "B":new Point(202,-20),
  46.             "cl":6710886,
  47.             "al":1
  48.          });
  49.          planes.push({
  50.             "A":new Point(202,-20),
  51.             "B":new Point(200,-20),
  52.             "cl":10066329,
  53.             "al":1
  54.          });
  55.          planes.push({
  56.             "A":new Point(200,-20),
  57.             "B":new Point(200,-290),
  58.             "cl":6697728,
  59.             "al":1
  60.          });
  61.          planes.push({
  62.             "A":new Point(200,-290),
  63.             "B":new Point(202,-290),
  64.             "cl":3355443,
  65.             "al":1
  66.          });
  67.          planes.push({
  68.             "A":new Point(202,-290),
  69.             "B":new Point(202,-310),
  70.             "cl":6710886,
  71.             "al":1
  72.          });
  73.          planes.push({
  74.             "A":new Point(202,-310),
  75.             "B":new Point(210,-310),
  76.             "cl":3355443,
  77.             "al":1
  78.          });
  79.          planes.push({
  80.             "A":new Point(210,-310),
  81.             "B":new Point(210,-320),
  82.             "cl":6710886,
  83.             "al":1
  84.          });
  85.          planes.push({
  86.             "A":new Point(-202,0),
  87.             "B":new Point(-202,-20),
  88.             "cl":6710886,
  89.             "al":1
  90.          });
  91.          planes.push({
  92.             "A":new Point(-202,-20),
  93.             "B":new Point(-200,-20),
  94.             "cl":10066329,
  95.             "al":1
  96.          });
  97.          planes.push({
  98.             "A":new Point(-200,-20),
  99.             "B":new Point(-200,-290),
  100.             "cl":6697728,
  101.             "al":1
  102.          });
  103.          planes.push({
  104.             "A":new Point(-200,-290),
  105.             "B":new Point(-202,-290),
  106.             "cl":3355443,
  107.             "al":1
  108.          });
  109.          planes.push({
  110.             "A":new Point(-202,-290),
  111.             "B":new Point(-202,-310),
  112.             "cl":6710886,
  113.             "al":1
  114.          });
  115.          planes.push({
  116.             "A":new Point(-202,-310),
  117.             "B":new Point(-210,-310),
  118.             "cl":3355443,
  119.             "al":1
  120.          });
  121.          planes.push({
  122.             "A":new Point(-210,-310),
  123.             "B":new Point(-210,-320),
  124.             "cl":6710886,
  125.             "al":1
  126.          });
  127.       }
  128.       
  129.       public function onRemove(param1:Event) : *
  130.       {
  131.          removeEventListener(Event.ENTER_FRAME,render);
  132.          removeEventListener(Event.REMOVED_FROM_STAGE,onRemove);
  133.       }
  134.       
  135.       public function drawPlane(param1:*) : *
  136.       {
  137.          var _loc2_:* = undefined;
  138.          var _loc3_:* = undefined;
  139.          var _loc4_:* = undefined;
  140.          var _loc5_:* = undefined;
  141.          var _loc6_:* = undefined;
  142.          var _loc7_:* = undefined;
  143.          var _loc8_:* = undefined;
  144.          var _loc9_:* = undefined;
  145.          var _loc10_:* = undefined;
  146.          var _loc11_:* = undefined;
  147.          var _loc12_:* = undefined;
  148.          var _loc13_:* = undefined;
  149.          _loc2_ = new Point(pp.x - (x + param1.A.x),pp.y - y);
  150.          _loc3_ = Math.atan2(_loc2_.y,_loc2_.x);
  151.          _loc4_ = -deep * (1 / Math.tan(_loc3_));
  152.          _loc5_ = new Point(pp.x - (x + param1.A.x),pp.y - (y + param1.A.y));
  153.          _loc6_ = Math.atan2(_loc5_.y,_loc5_.x);
  154.          _loc7_ = _loc4_ * Math.tan(_loc6_);
  155.          _loc8_ = new Point(pp.x - (x + param1.B.x),pp.y - y);
  156.          _loc9_ = Math.atan2(_loc8_.y,_loc8_.x);
  157.          _loc10_ = -deep * (1 / Math.tan(_loc9_));
  158.          _loc11_ = new Point(pp.x - (x + param1.B.x),pp.y - (y + param1.B.y));
  159.          _loc12_ = Math.atan2(_loc11_.y,_loc11_.x);
  160.          _loc13_ = _loc10_ * Math.tan(_loc12_);
  161.          graphics.beginFill(param1.cl,param1.al);
  162.          graphics.moveTo(param1.A.x,param1.A.y);
  163.          graphics.lineTo(param1.A.x + _loc4_,param1.A.y + _loc7_);
  164.          graphics.lineTo(param1.B.x + _loc10_,param1.B.y + _loc13_);
  165.          graphics.lineTo(param1.B.x,param1.B.y);
  166.          graphics.lineTo(param1.A.x,param1.A.y);
  167.          graphics.endFill();
  168.       }
  169.       
  170.       public function render(param1:Event) : *
  171.       {
  172.          var _loc2_:* = undefined;
  173.          graphics.clear();
  174.          _loc2_ = 0;
  175.          while(_loc2_ < planes.length)
  176.          {
  177.             drawPlane(planes[_loc2_]);
  178.             _loc2_++;
  179.          }
  180.       }
  181.       
  182.       public function addElements() : *
  183.       {
  184.          var _loc1_:* = undefined;
  185.          var _loc2_:* = undefined;
  186.          var _loc3_:* = undefined;
  187.          var _loc4_:MovieClip = null;
  188.          _loc1_ = new Point(pp.x - x,pp.y - y);
  189.          _loc2_ = Math.atan2(_loc1_.y,_loc1_.x);
  190.          _loc3_ = 1 / Math.tan(_loc2_);
  191.          (_loc4_ = new step3()).x = x + 145 + _loc4_.deep * _loc3_;
  192.          _loc4_.y = 340;
  193.          scope.elementArray.push(_loc4_);
  194.          scope.element.addChild(_loc4_);
  195.       }
  196.    }
  197. }
  198.